﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Security.Cryptography;

namespace Dubs_Finder.Model
{
    public class Hasher
    {
        private FileStream fs;
        private MD5 md5sum;
        public string HashString { get; private set; }

        public Hasher(FileInfo file, bool isAsync)
        {
            this.fs = file.Open(FileMode.Open, FileAccess.Read);

            this.fs.Position = 0;
        }

        public void ComputeHash()
        {
            this.md5sum = MD5.Create();
            byte[] hash = this.md5sum.ComputeHash(this.fs);
            //hash = Encoding.Convert(Encoding.GetEncoding("iso-8859-1"), Encoding.UTF8, hash);
            //this.HashString = Encoding.Default.GetString(hash);
            foreach (byte b in hash)
                Debug.Write(b.ToString("X"));

            //We're done! No more program-on-file action.
            this.fs.Close();
        }
    }
}
